home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / mflms101.arc / MFLFILES.H < prev    next >
C/C++ Source or Header  |  1989-11-25  |  13KB  |  327 lines

  1. /************************************************************************/
  2. /*                                                                      */
  3. /*  MFLFILES Header file                                                */
  4. /*                                                                      */
  5. /*  Function prototypes for file system access functions.               */
  6. /*                                                                      */
  7. /*  Copyright 1989 by Robert B. Stout dba MicroFirm                     */
  8. /*  All rights reserved                                                 */
  9. /*                                                                      */
  10. /*  Copyright 1986, 1987 by S.E. Margison                               */
  11. /*                                                                      */
  12. /*  Compiled by QC 2.0 for use with MSC 5.1 or QC 2.0 or later.         */
  13. /*                                                                      */
  14. /************************************************************************/
  15.  
  16. #ifndef MFLFILES_H
  17. #define MFLFILES_H
  18.  
  19. #include <stdio.h>
  20. #include <dos.h>
  21. #include <mfldefs.h>
  22.  
  23. /*
  24. **  ANSI definitions
  25. */
  26.  
  27. #ifndef _Cdecl_
  28.  #ifdef NO_EXT_KEYS
  29.   #define _Cdecl_
  30.  #else
  31.   #define _Cdecl_ cdecl
  32.  #endif
  33. #endif
  34.  
  35. /************************************************************************/
  36. /*                                                                      */
  37. /*  Check for the existance of a file                                   */
  38. /*                                                                      */
  39. /************************************************************************/
  40.  
  41. int     _Cdecl_ exists(char *);
  42.              
  43. /************************************************************************/
  44. /*                                                                      */
  45. /*  Change/verify disk drives or directories                            */
  46. /*                                                                      */
  47. /************************************************************************/
  48.  
  49. int     _Cdecl_ chdrv(char);
  50. LOGICAL _Cdecl_ drvalid(char);
  51. char    _Cdecl_ getdrv(void);
  52. int     _Cdecl_ pushdir(char *);
  53. int     _Cdecl_ popdir(void);
  54.  
  55. /************************************************************************/
  56. /*                                                                      */
  57. /*  File operations using FCB functions                                 */
  58. /*                                                                      */
  59. /************************************************************************/
  60.  
  61. struct XFCB
  62. {
  63.         unsigned char header[6];
  64.         unsigned char attribute;
  65.         unsigned char drive;
  66.         unsigned char fname[8];
  67.         unsigned char fext[3];
  68.         int curr_block;
  69.         int rec_size;
  70.         long file_size;
  71.         unsigned int date;
  72.         unsigned int time;
  73.         char reserved[8];
  74.         unsigned char curr_rec;
  75.         long rand_rec;
  76. } ;
  77.  
  78. int           _Cdecl_ FCB_creat(char *, int);
  79. int           _Cdecl_ FCB_kill(char *, int);
  80. struct XFCB * _Cdecl_ FCB_open(char *, int);
  81. int           _Cdecl_ FCB_close(struct XFCB *);
  82. int           _Cdecl_ FCB_reads(struct XFCB *, void *);
  83. int           _Cdecl_ FCB_writes(struct XFCB *, void *);
  84. int           _Cdecl_ FCB_readr(struct XFCB *, void *, long);
  85. int           _Cdecl_ FCB_writer(struct XFCB *, void *, long);
  86.  
  87. /************************************************************************/
  88. /*                                                                      */
  89. /*  Manipulate volume labels                                            */
  90. /*                                                                      */
  91. /************************************************************************/
  92.  
  93. char  * _Cdecl_    flretvol(char);
  94. int    _Cdecl_ flremvol(char);
  95. int    _Cdecl_ flsetvol(char, char *);
  96.  
  97. /************************************************************************/
  98. /*                                                                      */
  99. /*  Delete files using FCB's - very fast with wildcards!                */
  100. /*                                                                      */
  101. /************************************************************************/
  102.  
  103. int     _Cdecl_ del_files(char *, char *);
  104.  
  105. /************************************************************************/
  106. /*                                                                      */
  107. /*  Copy files                                                          */
  108. /*                                                                      */
  109. /************************************************************************/
  110.  
  111. int     _Cdecl_ fcopy(char *, char *, int);
  112.  
  113. /************************************************************************/
  114. /*                                                                      */
  115. /*  Expand command line wildcard arguments                              */
  116. /*                                                                      */
  117. /************************************************************************/
  118.  
  119. extern char **nargv;
  120. int _Cdecl_ expand_args(int, char *[]);
  121.  
  122. /************************************************************************/
  123. /*                                                                      */
  124. /*  Directory operations using file-type functions                      */
  125. /*                                                                      */
  126. /************************************************************************/
  127.  
  128. typedef struct
  129. {
  130.         int             dd_fd;
  131.         unsigned        dd_loc,
  132.                         dd_size;
  133.         struct find_t   dd_buf;
  134.         char            dd_dirname[MAX_FLEN];
  135. } DOS_DIR;
  136.  
  137. DOS_DIR       * _Cdecl_ opendir(char *);
  138. void            _Cdecl_ closedir(DOS_DIR *);
  139. struct find_t * _Cdecl_ readdir(DOS_DIR *);
  140. int            _Cdecl_ dirmask(struct find_t *,char *,char *,unsigned,unsigned);
  141.  
  142. extern int DFerr;
  143.  
  144. extern DOS_DIR _DIRS[];
  145.  
  146. /************************************************************************/
  147. /*                                                                      */
  148. /*  Stream functions for installable stream filters.                    */
  149. /*                                                                      */
  150. /************************************************************************/
  151.  
  152. typedef struct {
  153.     int  idx;
  154.     char mode[4];
  155.     FILE *fp;
  156.     int flag;            /* Bit-mapped - 0-7  current char
  157.                             8-12 undefined
  158.                             13   in use
  159.                             14   locked
  160.                             15   eof    */
  161.  
  162. #define SF_CHAR_MASK    0xff
  163. #define SF_EOF_MASK    0x8000
  164. #define SF_CHEOF_MASK    0x80ff
  165. #define SF_LOCK_MASK    0x4000
  166. #define SF_INUSE_MASK    0x2000
  167.  
  168.     int  ( _Cdecl_ *hook)();
  169.     int  ( _Cdecl_ *unhook)();
  170.     void ( _Cdecl_ *chain)(char *, int);
  171.     void ( _Cdecl_ *flush)(int);
  172.     } SFILE;
  173.  
  174. #define SFOPEN_MAX FOPEN_MAX + 16
  175.  
  176. extern  SFILE _siob[SFOPEN_MAX];
  177.  
  178. typedef struct {
  179.     void ( _Cdecl_ *filt)(char *, int);
  180.     void ( _Cdecl_ *flush)(int);
  181.     void ( _Cdecl_ *chain[SFOPEN_MAX])(char *, int);
  182.     } SFILTER;
  183.  
  184. SFILE * _Cdecl_ sfopen(const char *, const char *);
  185. int     _Cdecl_ sclose(SFILE *);
  186. int     _Cdecl_ sfputc(int, SFILE *);
  187. int     _Cdecl_ sfputs(const char *, SFILE *);
  188. size_t   _Cdecl_ sfwrite(const void *, size_t, size_t, SFILE *);
  189. int     _Cdecl_ sfgetc(SFILE *);
  190. char  * _Cdecl_ sfgets(const void *, int, SFILE *);
  191. size_t   _Cdecl_ sfread(const void *, size_t, size_t, SFILE *);
  192. LOGICAL _Cdecl_ sfinstall(SFILE *, SFILTER *);
  193.  
  194. /************************************************************************/
  195. /*                                                                      */
  196. /*  Simple stream filters                                               */
  197. /*                                                                      */
  198. /************************************************************************/
  199.  
  200. extern SFILTER    ucase_filt,
  201.         lcase_filt;
  202.  
  203. /************************************************************************/
  204. /*                                                                      */
  205. /*  Stream encryption function                                          */
  206. /*                                                                      */
  207. /************************************************************************/
  208.  
  209. int _Cdecl_ crypt_install(SFILE *, char *, int);
  210.  
  211. /************************************************************************/
  212. /*                                                                      */
  213. /*  Stream compression/expansion functions                              */
  214. /*                                                                      */
  215. /************************************************************************/
  216.  
  217. int _Cdecl_ ncode_install(SFILE *);
  218. int _Cdecl_ dcode_install(SFILE *);
  219.  
  220. /************************************************************************/
  221. /*                                                                      */
  222. /*  File truncation functions                                           */
  223. /*                                                                      */
  224. /************************************************************************/
  225.  
  226. int     _Cdecl_ trunc(int, long);
  227. int     _Cdecl_ ftrunc(FILE *, long);
  228. int     _Cdecl_ truncate(char *, long);
  229.  
  230. /************************************************************************/
  231. /*                                                                      */
  232. /*  Filename parsing functions                                          */
  233. /*                                                                      */
  234. /************************************************************************/
  235.  
  236. #define EXTENSION 1
  237. #define FILENAME  2
  238. #define DIRECTORY 4
  239. #define DRIVE     8
  240. #define WILDNAME  16
  241. #define WILDPATH  32
  242.  
  243. int    _Cdecl_ fnsplit(char *,char *,char *,char *,char *,char *,char *);
  244. char * _Cdecl_ fnmerge(char *,char *,char *,char *,char *,char *,char *);
  245. int    _Cdecl_ has_wild(char *);
  246.  
  247. #define DOS_STYLE   1
  248. #define UNIX_STYLE  2
  249. #define BOTH_STYLES 3
  250.  
  251. int    _Cdecl_ wildname(char *, char *, int);
  252.  
  253. /************************************************************************/
  254. /*                                                                      */
  255. /*  Normalize file names                                                */
  256. /*                                                                      */
  257. /************************************************************************/
  258.  
  259. int     _Cdecl_ flnorm(char *, char *);
  260. char *  _Cdecl_ fln_fix(char *);
  261. char *  _Cdecl_ unix2dos(char *);
  262.  
  263. /************************************************************************/
  264. /*                                                                      */
  265. /*  Open files using a path specification                               */
  266. /*                                                                      */
  267. /************************************************************************/
  268.  
  269. FILE * _Cdecl_ fopenp(char *, char *),
  270.      * _Cdecl_ fopeng(char *, char *, char *),
  271.      * _Cdecl_ fopend(char *, char *, char *);
  272.  
  273. int    _Cdecl_ openp(char *, int),
  274.        _Cdecl_ opend(char *, int, char *),
  275.        _Cdecl_ openg(char *, int, char *),
  276.        _Cdecl_ getpath(char *);
  277.  
  278. /************************************************************************/
  279. /*                                                                      */
  280. /*  Structures & functions for accessing file dates and times           */
  281. /*                                                                      */
  282. /************************************************************************/
  283.  
  284. #ifndef FTIME_DEF__
  285. #define FTIME_DEF__
  286.  
  287. struct ftime {
  288.         unsigned int ft_tsec  : 5;
  289.         unsigned int ft_min   : 6;
  290.         unsigned int ft_hour  : 5;
  291.         unsigned int ft_day   : 5;
  292.         unsigned int ft_month : 4;
  293.         unsigned int ft_year  : 7;
  294.         } ;
  295.  
  296. int     _Cdecl_ getftime(int, struct ftime *);
  297. int     _Cdecl_ setftime(int, struct ftime *);
  298. int     _Cdecl_ touch(char *);
  299. void    _Cdecl_ get_filetime(struct tm *, int);
  300.  
  301. #endif /* FTIME_DEF__ */
  302.  
  303. /************************************************************************/
  304. /*                                                                      */
  305. /*  File extension functions                                            */
  306. /*                                                                      */
  307. /************************************************************************/
  308.  
  309. void _Cdecl_ badext(char *),
  310.      _Cdecl_ newext(char *, char *, char *);
  311. int  _Cdecl_ exttyp(char *, char *);
  312.  
  313. /************************************************************************/
  314. /*                                                                      */
  315. /*  Miscellaneous functions                                             */
  316. /*                                                                      */
  317. /************************************************************************/
  318.  
  319. void _Cdecl_ eraok(char *),
  320.      _Cdecl_ cant(char *),
  321.      _Cdecl_ exit2dos(void);
  322.  
  323. int  _Cdecl_ repchar(char, int, FILE *),
  324.      _Cdecl_ iscons(FILE *);
  325.  
  326. #endif /* MFLFILES_H */
  327.